/*
 * Copyright 2013 JROSE
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jrose.service.user;

import lombok.Data;
import org.apache.commons.lang3.Validate;
import org.jrose.entity.constant.Gender;
import org.jrose.entity.constant.Race;

import java.io.Serializable;

/**
 * User signup context data structure.
 *
 * @author Xiaohai Zhang
 * @serial
 * @since 2013-09-01 16:36
 */
@Data
public class UserSignupContext implements Serializable {
    private static final long serialVersionUID = -1115106974138405533L;

    private String username;
    private String password;
    private String rolename;
    private Race race;
    private Gender gender;

    public void validate() {
        Validate.notNull(username, "Username must not be null");
        Validate.isTrue(username.length() >= 1 && username.length() <= 16, "Illegal username");
        Validate.notNull(rolename, "Rolename must not be null");
        Validate.isTrue(rolename.length() >= 1 && rolename.length() <= 16, "Illegal rolename");
        Validate.notNull(race, "Race must not be null");
        Validate.notNull(gender, "Gender must not be null");
    }
}
